<template>
  <view class="bottom-tab-bar">
    <view v-for="(tab, idx) in tabs" :key="idx" :class="['tab-item', {active: current === idx}]" @click="onTab(idx)">
      <image class="tab-icon-img" :src="tab.icon" />
      <text class="tab-label">{{tab.label}}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    current: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      tabs: [
        { label: '首页', icon: '/static/tabbar/shouye.png', path: '/pages/index/index' },
        { label: '订单', icon: '/static/tabbar/dingdan.png', path: '/pages/order/order' },
        { label: '预约', icon: '/static/tabbar/order.png', path: '/pages/reserve/reserve' }
      ]
    };
  },
  methods: {
    onTab(idx) {
      if (this.current !== idx) {
        uni.navigateTo({ url: this.tabs[idx].path });
      }
    }
  }
};
</script>

<style>
.bottom-tab-bar {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100vw;
  height: 100rpx;
  background: #fff;
  box-shadow: 0 -2rpx 8rpx #eee;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 9999;
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #222;
  font-size: 22rpx;
  padding: 0;
}
.tab-item.active {
  color: #ff6a00;
}
.tab-icon-img {
  width: 48rpx;
  height: 48rpx;
  margin-bottom: 2rpx;
}
.tab-label {
  font-size: 22rpx;
}
</style>
